import Cookies from 'js-cookie'

const TokenKey = 'accessToken'

export function getToken () {
  return Cookies.get(TokenKey)
}

export function expireToken () {
  return setToken(Cookies.get(TokenKey))
}

export function setToken (token) {
  var expiresTime = new Date(new Date().getTime() + (2 * 60 * 60 * 1000))// 设置 cookies的过期时间为2小时
  return Cookies.set(TokenKey, token, { expires: expiresTime })
  // return Cookies.set(TokenKey, token)
}

export function removeToken () {
  return Cookies.remove(TokenKey)
}
